#include <iostream>
#include <vector>
#include <sstream>
#include <algorithm>

int main()
{
    int len;
    std::cin >> len;
    std::cin.ignore();

    std::string s;
    // std::getline(std::cin, s);
    // std::istringstream iss(s);

    std::vector<int> nums;
    int num;
    for (int i = 0; i < len; i++)
    {
        std::cin >> num;
        nums.push_back(num);
    }
    // while (iss >> num)
    // {
    //     nums.push_back(num);
    // }

    int total = 0;
    for (int i = 0; i < nums.size(); i++)
    {
        total += nums[i];
    }

    int max_diff = 0;
    int l = 0;
    int r = total;
    for (int i = 1; i < nums.size(); i++)
    {
        l = l + nums[i - 1];
        r = r - nums[i - 1];
        std::cout << l << " " << r << std::endl;
        int diff = abs(l - r);
        if (max_diff < diff)
        {
            max_diff = diff;
        }
    }

    std::cout << max_diff << std::endl;
    return 0;
}